/**
 * CourseStructureModule.java
 * com.sftz.modules.minapp.coursestructure.module
 * Copyright (c) 2018, 北京科技有限公司版权所有.
*/

package com.sftz.modules.minapp.coursestructure.module;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import com.sftz.framework.rersult.MobileResult;
import com.sftz.modules.minapp.coursestructure.form.CourseStructureForm;
import com.sftz.modules.minapp.coursestructure.service.CourseStructureViewService;

/**
 * @author   闫志彬
 * @Date	 2018年12月13日 	 
 */
@IocBean
@At("/wx/coursestructure")
@Filters
public class CourseStructureModule {

	@Inject
	private CourseStructureViewService courseStructureViewService;

	/**
	 * 查询课程结构列表
	 */
	@At
	@Ok("json")
	public Object getCourseStructure(@Param("..") final CourseStructureForm courseStructureForm) {
		try {
			Object courseStructure = courseStructureViewService.getCourseStructure(courseStructureForm);
			return MobileResult.success("", courseStructure);
		} catch (Exception e) {
			e.printStackTrace();
			return MobileResult.error("", "");
		}
	}

	/**
	 * 查询课程结构详细信息
	 */
	@At
	@Ok("json")
	public Object getCourseStructureDetails(@Param("..") final CourseStructureForm courseStructureForm) {
		try {
			Object courseStructureDetails = courseStructureViewService.getCourseStructureDetails(courseStructureForm);
			return MobileResult.success("", courseStructureDetails);
		} catch (Exception e) {
			e.printStackTrace();
			return MobileResult.error("", "");
		}
	}

	/**
	 * 直接根据层级的id 去查询具体资源信息
	 */
	@At
	@Ok("json")
	public Object findCourseStructureResourceDetailsInforById(@Param("..") final CourseStructureForm courseStructureForm) {
		try {
			Object findCourseStructureResourceDetailsInforById = courseStructureViewService
					.findCourseStructureResourceDetailsInforById(courseStructureForm);
			return MobileResult.success("", findCourseStructureResourceDetailsInforById);
		} catch (Exception e) {
			e.printStackTrace();
			return MobileResult.error("", "");
		}
	}
}
